import Vue from 'vue';
import Router from 'vue-router';
const _import = require('./_import_' + process.env.NODE_ENV);
// in development env not use Lazy Loading,because Lazy Loading large page will cause webpack hot update too slow.so only in production use Lazy Loading

Vue.use(Router);

/* layout */
import Layout from '../views/layout/Layout';

/**
 * icon : the icon show in the sidebar
 * hidden : if `hidden:true` will not show in the sidebar
 * redirect : if `redirect:noredirect` will no redirct in the levelbar
 * noDropdown : if `noDropdown:true` will has no submenu
 * meta : { role: ['admin'] }  will control the page role
 **/
export const constantRouterMap = [{
		path: '/login',
		name: '登录',
		component: _import('login/index'),
		hidden: true
	},
	{
		path: '/authredirect',
		component: _import('login/authredirect'),
		hidden: true
	},
	{
		path: '/404',
		component: _import('error/404'),
		hidden: true
	},
	{
		path: '/401',
		component: _import('error/401'),
		hidden: true
	},
	{
		path: '/',
		component: Layout,
		redirect: '/welcome',
		name: '首页',
		hidden: true,
		children: [{
			path: 'dashboard',
			redirect: '/welcome',
			component: _import('dashboard/index'),
		}]
	},
	{
		path: '/',
		component: Layout,
		name: '',
		hidden: true,
		children: [{
			path: 'welcome',
			component: _import('welcome/index'),
		}]
	},
]

export default new Router({
	mode: 'history', //后端支持可开
	scrollBehavior: () => ({
		y: 0
	}),
	routes: constantRouterMap
});

export const asyncRouterMap = [{
	path: '',
	component: Layout,
	name: '基础配置管理',
	authority: 'baseManager',
	children: [{
		path: 'user',
		component: _import('admin/user/index'),
		name: '用户管理',
		authority: 'userManager'
	}, {
		path: 'menu',
		component: _import('admin/menu/index'),

		name: '菜单管理',
		authority: 'menuManager'
	}, {
		path: 'group',
		component: _import('admin/group/index'),
		name: '角色权限管理',
		authority: 'groupManager'
	}, {
		path: 'group_type',
		component: _import('admin/groupType/index'),
		name: '角色类型管理',
		authority: 'groupTypeManager'
	}, {
		path: 'gate_log',
		component: _import('admin/gateLog/index'),
		name: '操作日志管理',
		authority: 'gateLogManager'
	}]
}, {
	path: '',
	component: Layout,
	name: '交易管理',
	authority: 'z_tradeManagement',
	children: [{
		path: 'trade',
		component: _import('z_tradeManagement/index'),
		name: '交易流水',
		authority: 'tradingFlow'
	}]
}, {
	path: '',
	component: Layout,
	name: '商户管理',
	authority: 'z_businessManagement',
	children: [{
		path: 'merchant',
		component: _import('z_businessManagement/index'),
		name: '商户',
		authority: 'merchant',
	}, {
		path: 'agent',
		component: _import('z_businessManagement/agent/index'),
		name: '代理商',
		authority: 'agent'
	}, ]
}, {
	path: '',
	component: Layout,
	name: '审核管理',
	authority: 'z_auditManage',
	children: [{
		path: 'merAudit',
		component: _import('z_auditManage/merAudit/index'),
		name: '商户审核',
		authority: 'merAudit'
	}, {
		path: 'shopAudit',
		component: _import('z_auditManage/shopAudit/index'),
		name: '店铺审核',
		authority: 'shopAudit'
	}, {
		path: 'agentAudit',
		component: _import('z_auditManage/agentAudit/index'),
		name: '代理商审核',
		authority: 'agentAudit'
	}, ]
}, {
	path: '',
	component: Layout,
	name: '终端管理',
	authority: 'z_terManage',
	children: [{
		path: 'paipai',
		component: _import('z_terManage/paipai/index'),
		name: '派派小盒',
		authority: 'paipai'
	}, {
		path: 'POS',
		component: _import('z_terManage/POS/index'),
		name: 'POS机',
		authority: 'POS'
	}, {
		path: 'solidCode',
		component: _import('z_terManage/solidCode/index'),
		name: '固码',
		authority: 'solidCode'
	}]
}, {
	path: '',
	component: Layout,
	name: '资金管理',
	authority: 'z_capManage',
	children: [{
		path: 'clear',
		component: _import('z_capManage/clear/index'),
		name: '清算',
		authority: 'clear'
	}, {
		path: 'balance',
		component: _import('z_capManage/balance/index'),
		name: '结算',
		authority: 'balance'
	}, {
		path: 'shareProfit',
		component: _import('z_capManage/shareProfit/index'),
		name: '分润',
		authority: 'shareProfit'
	}, {
		path: 'cash',
		component: _import('z_capManage/cash/index'),
		name: '兑现',
		authority: 'cash'
	}, {
		path: 'transferAccount',
		component: _import('z_capManage/transferAccount/index'),
		name: '调账',
		authority: 'transferAccount'
	}, {
		path: 'statementAccount',
		component: _import('z_capManage/statementAccount/index'),
		name: '对账单',
		authority: 'statementAccount'
	}]
}, {
	path: '',
	component: Layout,
	name: '通道管理',
	authority: 'z_passageway',
	children: [{
		path: 'passConfig',
		component: _import('z_passageway/passConfig/index'),
		name: '通道配置',
		authority: 'passConfig'
	}]
}, {
	path: '',
	component: Layout,
	name: '机构管理',
	authority: 'z_mechanism',
	children: [{
		path: 'mechanism',
		component: _import('z_mechanism/mechanism/index'),
		name: '机构管理',
		authority: 'mechanism'
	}]
}, {
	path: '',
	icon: 'Device',
	component: Layout,
	name: '设备',
	authority: 'device',
	children: [{
		path: 'deviceManagement',
		icon: 'Device',
		component: _import('z_deviceManagement/index'),
		name: '设备管理',
		authority: 'deviceManagement'
	}, {
		path: 'solidCode',
		icon: 'Device',
		component: _import('z_solidCode/index'),
		name: '固码',
		authority: 'solidCode'
	}, ]
}, {
	path: '',
	icon: 'cash-cny',
	component: Layout,
	name: '财务',
	authority: 'withdrawCash',
	children: [{
		path: 'merchantWithdrawCash',
		icon: 'cash-cny',
		component: _import('z_merchantWithdrawCash/index'),
		name: '商户提现',
		authority: 'merchantWithdrawCash'
	}]
}, {
	path: '',
	icon: 'cash-cny',
	component: Layout,
	name: '人员管理',
	authority: 'personnelManagement',
	children: [{
		path: 'salesmanManagement',
		icon: 'cash-cny',
		component: _import('z_SalesmanManage/index'),
		name: '业务员管理',
		authority: 'salesmanManagement'
	}]
}, ];